package com.chrray.position.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.chrray.position.domain.dto.DeleteParam;
import com.chrray.position.domain.dto.FdAboutUsDTO;
import com.chrray.position.domain.dto.search.FdAboutUsSearch;
import com.chrray.position.domain.vo.FdAboutUsVO;
import com.chrray.position.service.position.FdAboutUsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 关于我们控制器
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */
@RestController
@RequestMapping("/api/app/about")
@Api(tags = "关于我们")
@AllArgsConstructor
public class FdAboutUsController {

    private final FdAboutUsService fdAboutUsService;

    @GetMapping("/pageList")
    @ApiOperation("分页列表")
    @ApiResponses({
        @ApiResponse(code=200, message = "ok", response = FdAboutUsVO.class)
    })
    public R<IPage<FdAboutUsVO>> pageList(@Valid FdAboutUsSearch param){
        return R.ok(fdAboutUsService.pageList(param));
    }

    @GetMapping("/{id}")
    @ApiOperation("查询详情")
    @ApiResponses({
        @ApiResponse(code=200, message = "ok", response = FdAboutUsVO.class)
    })
    public R<FdAboutUsVO> get(@ApiParam(name = "id",value = "主键id",required = true) @PathVariable("id") Long id){
        return R.ok(fdAboutUsService.info(id));
    }

    @PostMapping("/saveOrUpdate")
    @ApiOperation("新增编辑")
    public R<Boolean> saveOrUpdate(@RequestBody FdAboutUsDTO body){
        return R.ok(fdAboutUsService.saveOrUpdate(body));
    }

    @DeleteMapping("/remove")
    @ApiOperation("批量删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "idList", value = "主键数组")
    })
    public R<Boolean> delete(@RequestBody DeleteParam param){
        return R.ok(fdAboutUsService.delete(param.getIds()));
    }
}
